package com.example.walled_houses.controller;
import com.example.walled_houses.dto.LoginDTO;
import com.example.walled_houses.service.UserService;
import com.example.walled_houses.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chengtaoxie
 * @since 2023-10-24
 */
@CrossOrigin
@Api(tags = "用户信息接口")
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @ApiOperation("用户登录接口")
    @PostMapping("/login")
    public Result login(@RequestBody LoginDTO loginDto){
        return userService.login(loginDto);
    }


    @ApiOperation("查询用户信息")
    @GetMapping("/getUser")
    public Result getUser(){
        return userService.getUser();
    }

    @ApiOperation("修改用户头像")
    @PutMapping("/updateUserPhoto")
    public Result updateUserPhoto(@RequestBody MultipartFile file){
        return userService.updateUserPhoto(file);
    }



}

